function [debt2asset, equity_mv, debt_overhang] = debt2asset_fun(struct_input, firm_type)

RateSpec = struct_input.RateSpec;
StockSpec = struct_input.StockSpec;
OptSpec = struct_input.OptSpec;
Strike = struct_input.Strike;
Settle = struct_input.Settle;
Maturity = struct_input.Maturity;


if strcmp(firm_type, 'diverse')
    equity_mv = basketsensbyju(RateSpec, StockSpec, OptSpec, Strike, Settle, Maturity, 'OutSpec', {'Price'});
    weightvec = struct_input.investweightvec;
    equity_Delta = 0;
    for i = 1:length(weightvec)
        equity_Delta_i = basketsensbyju(RateSpec, StockSpec, OptSpec, Strike, Settle, Maturity, 'OutSpec', {'Delta'}, 'UndIdx', i);
        equity_Delta = equity_Delta + equity_Delta_i*weightvec(i);        
    end
    debt2asset = 1 - equity_mv/sum(StockSpec.AssetPrice);
elseif strcmp(firm_type, 'single')
    [equity_mv, equity_Delta] = optstocksensbybls(RateSpec, StockSpec, Settle, Maturity, OptSpec, Strike, 'OutSpec', {'Price', 'Delta'});
    debt2asset = 1 - equity_mv/StockSpec.AssetPrice;
end

debt_overhang = 1 - equity_Delta;